
import { getUserNationInfo,loadBasePeopleListNoPage } from "../../../services/self"
import { stat } from "fs";
export default {

  namespace: 'userInfoMation',

  state: {
    nation: [],
    nationality:[]
  },

  effects: {
    *getUserNation({ payload }, { call, put }) {
      let nav = yield getUserNationInfo(payload)
      yield put({
        type: 'changeNation', payload: [nav.map(s => {
          return {
            ...s,
            label:s.name,
            value:s.code
          }
        })]
      });
    },
    //获取民族列表
    *loadBasePeopleList({ payload }, { call, put }) {
      let nav = yield loadBasePeopleListNoPage(payload)
      yield put({
        type: 'changeNationality',
        payload:[nav.map(s =>{
          return {
            ...s,
            label:s.name,
            value:s.code
          }
        })]
      });

    },

    *fetch({ payload }, { call, put }) {  // eslint-disable-line
      yield put({ type: 'save' });
    },
  },

  reducers: {
    save(state, action) {
      return { ...state, ...action.payload };
    },
    changeNation(state, { payload }) {
      state.nation = payload;
      return {
        ...state,
        ...payload,
      }
    },
    changeNationality(state, { payload }) {
      state.nationality = payload;
      return {
        ...state,
        ...payload,
      }
    },
  },

};
